//
//  JJNetworkTask.swift
//  JJAlbumFramework
//
//  Created by 吴梓杭 on 2025/10/16.
//

import Foundation

enum JJNetworkTask {
    case getHashs
    // 获取资源列表
    case getFiles(current: Int, size: Int)
    // 获取资源
    case getFile(_ fileId: String)
    // 删除资源
    case deleteFile(_ fileId: String)
}

extension JJNetworkTask: YMTargetType {
    
    var path: String {
        switch self {
        case .getHashs:
            return "/media/md5s"
        case .getFiles:
            return "/media/user/media"
        case .getFile(let fileId), .deleteFile(let fileId):
            return "/media/{fileId}"
        }
    }
    
    var parameters: YMParameters {
        switch self {
        case .getFile, .deleteFile:
            var params = [String : Any]()
            params["userId"] = JJAlbumConfig.userId
            return params
        case .getFiles(let current, let size):
            var params = [String : Any]()
            params["userId"] = JJAlbumConfig.userId
            params["current"] = current
            params["size"] = size
            return params
        default:
            return [String: Any]()
        }
    }
    
    var method: YMMethod {
        switch self {
        case .deleteFile:
            return .delete
        default:
            return .get
        }
    }
    
}
